package com.ruoyi.web.controller.cs;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.cs.domain.TWarGrate;
import com.ruoyi.cs.domain.TWarUser;
import com.ruoyi.cs.domain.vo.TWarUserParamVo;
import com.ruoyi.cs.service.ITWarGrateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import java.util.List;
import java.util.Map;

/**
 * 战令等级Controller
 * 
 * @author ruoyi
 * @date 2023-12-11
 */
@Api(tags = {"战令等级模块后台系统"})
@RestController
@RequestMapping("/cs/war/grate")
public class TWarGrateController extends BasicsController
{
    @Autowired
    private ITWarGrateService tWarGrateService;

    /**
     * 查询战令等级列表
     */
    @ApiOperation("查询战令等级列表")
    @PreAuthorize("@ss.hasPermi('system:grate:list')")
    @GetMapping("/list/{warId}")
    public ResponsePageInfo<TWarGrate> list(@PathVariable("warId")String warId,@Validated TWarGrate tWarGrate)
    {
        tWarGrate.setWarId(warId);
        startPage(tWarGrate.getPageNum(),tWarGrate.getPageSize());
        List<TWarGrate> list = tWarGrateService.selectTWarGrateList(tWarGrate);
        return toResponsePageInfo(list);
    }

//    /**
//     * 获取战令等级详细信息
//     */
//    @ApiOperation("删除战令")
//    @PreAuthorize("@ss.hasPermi('system:grate:query')")
//    @GetMapping(value = "/{id}")
//    public Response<TWarGrate> getInfo(@PathVariable("id") Long id)
//    {
//        return Response.success(tWarGrateService.selectTWarGrateById(id));
//    }

    /**
     * 新增战令等级
     */
    @ApiOperation("新增战令等级")
    @PreAuthorize("@ss.hasPermi('system:grate:add')")
    @Log(title = "战令等级", businessType = BusinessType.INSERT)
    @PostMapping
    public Response add(@RequestBody TWarGrate tWarGrate)
    {
        return toResponse(tWarGrateService.insertTWarGrate(tWarGrate));
    }

    /**
     * 修改战令等级
     */
    @ApiOperation("修改战令等级")
    @PreAuthorize("@ss.hasPermi('system:grate:edit')")
    @Log(title = "战令等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response edit(@RequestBody TWarGrate tWarGrate)
    {
        return toResponse(tWarGrateService.updateTWarGrate(tWarGrate));
    }

    /**
     * 删除战令等级
     */
    @ApiOperation("删除战令等级")
    @PreAuthorize("@ss.hasPermi('system:grate:remove')")
    @Log(title = "战令等级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Response remove(@PathVariable Long[] ids)
    {
        return toResponse(tWarGrateService.deleteTWarGrateByIds(ids));
    }

    /**
     * @Desc: 战令参与用户列表
     * @author: zz
     * @date: 2023/12/12
     */
    @ApiOperation("战令参与用户列表")
    @PreAuthorize("@ss.hasPermi('system:grate:list')")
    @GetMapping("/waruser/{warId}")
    public ResponsePageInfo<TWarUser> warUserList(@PathVariable("warId")String warId,@ModelAttribute TWarUserParamVo tWarUserParamVo){
        tWarUserParamVo.setWarId(warId);
        startPage(tWarUserParamVo.getPageNum(),tWarUserParamVo.getPageSize());
        return toResponsePageInfo(tWarGrateService.warUserList(tWarUserParamVo));
    }

    @ApiOperation("获取战令箱子")
    @GetMapping("/getWarBoxList")
    public Response<List<Map<String, Object>>> getWarBoxList(@RequestParam(value = "searchValue",required = false) String searchValue){
        return Response.success(tWarGrateService.getWarBoxList(searchValue));
    }
}
